package model;

import java.sql.*;
import java.util.*;

public class CommentDAO {
	
	//자료시 컨텐츠 삭제
	public boolean DataCommentdelete(int cono) {
		Connection conn = ConnectionManager.getConnection();
		try {
			///////////////////////////////////////////////
			Statement stmt = conn.createStatement();
			String sql = "Delete FROM datacomment WHERE dbno in (SELECT dbno FROM databoard where cono="+cono+")"; 
			stmt.executeUpdate(sql);
			///////////////////////////////////////////////
			return true;
		} catch(Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			if(conn!=null) try { conn.close(); } catch(Exception e) {}
		}
	}
	
	
	//사진 컨텐츠 삭제
	public boolean PhotoCommentdelete(int cono) {
		Connection conn = ConnectionManager.getConnection();
		try {
			///////////////////////////////////////////////
			Statement stmt = conn.createStatement();
			String sql = "Delete FROM photocomment WHERE dbno in (SELECT dbno FROM photoboard where cono="+cono+")"; 
			stmt.executeUpdate(sql);
			///////////////////////////////////////////////
			return true;
		} catch(Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			if(conn!=null) try { conn.close(); } catch(Exception e) {}
		}
	}
	
	//자유 컨텐츠 삭제
	public boolean FreeCommentdelete(int cono) {
		Connection conn = ConnectionManager.getConnection();
		try {
			///////////////////////////////////////////////
			Statement stmt = conn.createStatement();
			String sql = "Delete FROM freecomment WHERE dbno in (SELECT dbno FROM freeboard where cono="+cono+")"; 
			stmt.executeUpdate(sql);
			///////////////////////////////////////////////
			return true;
		} catch(Exception e) {
			e.printStackTrace();
			return false;
		} finally {
			if(conn!=null) try { conn.close(); } catch(Exception e) {}
		}
	}
}
